﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UIControls;
using BO;
using Castle.ActiveRecord.Framework;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Framework.Config;
namespace UI.Tools
{
   public  class ClassForTest
    {
       void init()
       {
           // XmlConfigurationSource source = new XmlConfigurationSource("http://www.cnblogs.com/App.config");
           //// IConfigurationSource source = ConfigurationSettings.GetConfig("activerecord") as IConfigurationSource;
           // ActiveRecordStarter.Initialize(source, typeof(CastleLib.User));

           InPlaceConfigurationSource source = new InPlaceConfigurationSource();
           IDictionary<string, string> properties = new Dictionary<string, string>();
           properties.Add("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
           properties.Add("dialect", "NHibernate.Dialect.MsSql2008Dialect");
           properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
           properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
           properties.Add("connection.connection_string", "UID=sa;Password=1234;Initial Catalog=bjyxlA;Data Source=.;");
           source.Add(typeof(ActiveRecordBase), properties);
         //  ActiveRecordStarter.Initialize(source, typeof(BO.Company2));
       }
       public static void Excute()
       {
           try
           {
               var oc = new ClassForTest();
               oc.init();
       
   
             //  var obj = ActiveRecordBase<Company2>.FindAll();
           }
           catch(Exception exp)
           {
               throw exp;
           }
       }
    }
}
